package com.zh.note.huawei.onehundred.用户调度;

import java.util.Scanner;

/**
 * @Author: zhanghuan
 * @date: 2023/9/1 13:44
 * @description: create it
 */
public class Main {
    public static int sum = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] nums = new int[n][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                nums[i][j] = sc.nextInt();
            }
        }
        int index = nums[0][0] < nums[0][1] ? 0 : 1;
        index = nums[0][index] < nums[0][2] ? index : 2;
        sum = nums[0][index];
        for (int i = 1; i < n; i++) {
            index = find(index, nums[i]);
        }
        System.out.println(sum);
    }

    private static int find(int index, int[] num) {
        int temp = 0;
        if (index == 0) {
            temp = num[1] < num[2] ? 1 : 2;
            sum += num[temp];
        } else if (index == 1) {
            temp = num[0] < num[2] ? 0 : 2;
            sum += num[temp];
        } else {
            temp = num[0] < num[1] ? 0 : 1;
            sum += num[temp];
        }
        return temp;
    }
}
